How to print a pdf in a new tab? [migrated]
Posted
by
TheDuke777
on Programmers
See other posts from Programmers
or by TheDuke777
Published on 2013-07-02T20:44:57Z
Indexed on
2013/07/02
23:17 UTC
Read the original article
Hit count: 227
I need to print a pdf by opening it in a new window. I've looked at tutorials for days, but nothing is working. I've tried many approaches, but this is the most recent:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function print()
{
window.getElementById("pdf").focus();
window.getElementById("pdf").print();
}
</script>
</head>
<body onload="print()">
<embed id="pdf" src="http://path/to/file" />
</body>
</html>
The page loads fine, with the pdf embedded. But it won't print, and I feel like I've been beating my head against a brick wall trying to figure this out. How can I get this to work? I'm willing to try anything at this point.
© Programmers or respective owner